package com.longshine.plc.ui;

import com.longshine.util.NumberUtil;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import org.jdesktop.layout.GroupLayout;

public class AirCompressPanel extends OwnPanel
{
  private int pressValue;
  private JButton jButton3;
  private JButton jButton8;
  private JButton jButton9;
  private JLabel jLabel16;
  private JLabel jLabel19;
  private JLabel jLabel20;
  private JTextField jTextField4;
  private JTextField jTextField7;
  private JTextField jTextField8;

  public void init()
  {
    this.title = "空压机气压";
    ActionListener l = new ActionListener()
    {
      public void actionPerformed(ActionEvent e) {
        String comm = e.getActionCommand();
        if ((comm.equals("确定")) && (e.getSource() == AirCompressPanel.this.jButton3))
          AirCompressPanel.this.decimalChanged();
      }
    };
    this.jButton3.addActionListener(l);
    this.jTextField4.setText("61");
    decimalChanged();
  }

  public void decimalChanged() {
    this.pressValue = Integer.parseInt(this.jTextField4.getText());
    this.jTextField7.setText(NumberUtil.decimal2Binary(this.pressValue));
    this.jTextField8.setText(NumberUtil.toHexStr(this.pressValue, 2));
  }

  public int getPressValue() {
    return this.pressValue;
  }

  public AirCompressPanel()
  {
    initComponents();
  }

  private void initComponents()
  {
    this.jButton9 = new JButton();
    this.jLabel20 = new JLabel();
    this.jTextField8 = new JTextField();
    this.jLabel19 = new JLabel();
    this.jLabel16 = new JLabel();
    this.jTextField4 = new JTextField();
    this.jButton3 = new JButton();
    this.jButton8 = new JButton();
    this.jTextField7 = new JTextField();

    this.jButton9.setText("确定");

    this.jLabel20.setText("十六进制");

    this.jLabel19.setText("二进制");

    this.jLabel16.setText("气压值：");

    this.jButton3.setText("确定");

    this.jButton8.setText("确定");

    GroupLayout layout = new GroupLayout(this);
    setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(1)
      .add(layout.createSequentialGroup()
      .add(74, 74, 74)
      .add(layout.createParallelGroup(1)
      .add(this.jLabel16)
      .add(this.jLabel19)
      .add(this.jLabel20))
      .add(82, 82, 82)
      .add(layout.createParallelGroup(1, false)
      .add(this.jTextField4)
      .add(this.jTextField7)
      .add(this.jTextField8, -1, 218, 32767))
      .addPreferredGap(1)
      .add(layout.createParallelGroup(1, false)
      .add(this.jButton8, -1, -1, 32767)
      .add(this.jButton9, -1, -1, 32767)
      .add(this.jButton3, -1, -1, 32767))
      .addContainerGap(-1, 32767)));

    layout.setVerticalGroup(
      layout.createParallelGroup(1)
      .add(layout.createSequentialGroup()
      .add(75, 75, 75)
      .add(layout.createParallelGroup(3)
      .add(this.jLabel16)
      .add(this.jTextField4, -2, -1, -2)
      .add(this.jButton3))
      .add(33, 33, 33)
      .add(layout.createParallelGroup(3)
      .add(this.jLabel19)
      .add(this.jTextField7, -2, -1, -2)
      .add(this.jButton8))
      .add(29, 29, 29)
      .add(layout.createParallelGroup(3)
      .add(this.jLabel20)
      .add(this.jTextField8, -2, -1, -2)
      .add(this.jButton9))
      .addContainerGap(94, 32767)));
  }
}